package restfuljobs

import static org.grails.jaxrs.response.Responses.*

import javax.ws.rs.Consumes
import javax.ws.rs.GET
import javax.ws.rs.Produces
import javax.ws.rs.Path
import javax.ws.rs.PathParam
import javax.ws.rs.POST
import javax.ws.rs.core.Response
import javax.ws.rs.QueryParam

@Path('/api/jobApplicationReview')
@Consumes(['application/xml','application/json'])
@Produces(['application/xml','application/json'])
class JobApplicationReviewCollectionResource {

    def jobApplicationReviewResourceService
    
    @POST
    Response create(JobApplicationReview dto) {
        created jobApplicationReviewResourceService.create(dto)
    }

    @GET
    Response readAll(@QueryParam("userId") Long userId) {
				
		if (!userId) {
			throw new AccessDeniedException(JobApplication.class, userId)
		}
		
        ok jobApplicationReviewResourceService.readAll(userId)
    }
    
    @Path('/{id}')
    JobApplicationReviewResource getResource(@PathParam('id') Long id) {
        new JobApplicationReviewResource(jobApplicationReviewResourceService: jobApplicationReviewResourceService, id:id)
    }
        
}
